package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.entity.CanalThreeClassify;
import cn.stylefeng.guns.modular.business.pojo.EventsInfoRequest;
import cn.stylefeng.guns.modular.business.service.CanalThreeClassifyService;
import cn.stylefeng.guns.modular.business.service.EventsInfoService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@ApiResource(name="大事记controller")
@RestController
//@CrossOrigin(origins = "*",allowedHeaders = "*",methods = {},allowCredentials = "true")
public class EventsInfoController {
    @Resource
    private EventsInfoService eventsInfoService;
    @Resource
    private CanalThreeClassifyService canalThreeClassifyService;

    @GetResource(path = "/eventsinfo/toEventReview")
    public ResponseData toEventReview(String id) {

        return new SuccessResponseData(eventsInfoService.toEventReview(id));
    }

    @GetResource(path = "/eventsinfo/findLike")
    public ResponseData findLike(String name) {
        EventsInfoRequest eventsInfoRequest = new EventsInfoRequest();
        if(!name.isEmpty()) {
            eventsInfoRequest.setTheCommon(name);
        }
        return new SuccessResponseData(eventsInfoService.findList(eventsInfoRequest));
    }

    @GetResource(path = "/eventsinfo/getThreeCalssfiy")
    public ResponseData getThreeCalssfiy(String code) {
        CanalThreeClassify canalThreeClassfiy = new CanalThreeClassify();
        if(!code.isEmpty()) {
            canalThreeClassfiy.setCanalSecondClassifyCode(code);
        }
        return new SuccessResponseData(eventsInfoService.getThreeList(canalThreeClassfiy));
    }
}
